"use strict"
/**
 *
 * @param {import("egg").Application} app
 */
module.exports = app => {
	const Sequelize = app.Sequelize
	const sequelize = app.model
	// let AdminUser = sequelize.models.AdminUser

	let Application = sequelize.define("application", {
		applicat_name: {
			type: Sequelize.STRING(20),
		},
		account_id: {//关联管理员的账号id
			type: Sequelize.INTEGER,
		},
		app_id: {
			type: Sequelize.STRING(20),
			validate: {
				isAlphanumeric: true
			}
		},
		app_secret: {
			type: Sequelize.STRING(32),
		},
		base_id: {
			type: Sequelize.STRING(16),
		},
		token: {
			type: Sequelize.STRING(20),
		},
		encoding_aeskey: {
			type: Sequelize.STRING(43),
		},
		server_url: {
			type: Sequelize.STRING(100),
		},
		//消息通信
		app_type: {
			type: Sequelize.TINYINT,
			validate: {isInt: true}
		},
		create_at: {
			type: Sequelize.DATE,
			defaultValue: sequelize.literal("CURRENT_TIMESTAMP"),
			get() {
				return Date.parse(this.getDataValue("create_at"))
			}
		},
		head_url: {
			comment: "head_url //存储本地访问地址或者网络地址",
			type: Sequelize.STRING(100),

		},
		qrcode_url: {
			comment: "qrcode_url //存储本地访问地址或者网络地址",
			type: Sequelize.STRING(100),
		},
		version: {
			comment: "版本",
			type: Sequelize.INTEGER,
			defaultValue: 1
		},
		qr_scene_str: Sequelize.STRING,
	}, {
		tableName: "application",
		timestamps: false
	})
	Application.AppType = {
		MINI_PROGRAM: 1,
		MINI_GAME: 2,
		SERVICE_ACCOUNT: 3,//服务号
		SUBSCRIP_ACCOUNT: 4,//订阅号
		CERT_SERVICE_ACCOUNT: 5,//认证服务号
		CERT_SUBSCRIP_ACCOUNT: 6,// 认证订阅
	}
	//小程序 1 小游戏2  服务号3 
	// 订阅号 4 认证服务号5 认证订阅号6
	return Application
}
